//
//  HMTabbar.m
//  weiboOC
//
//  Created by 刘耀宗 on 16/4/8.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

#import "HMTabbar.h"
#import <UIKit/UIKit.h>
@interface HMTabbar ()
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, assign) NSInteger count;
@property (nonatomic, strong) UIButton *button;

@end


@implementation HMTabbar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}
-(void)setup
{//创建按钮
    UIButton *btn=[[UIButton alloc] init];
    self.button=btn;
    [self addSubview:btn];
    [self.button setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
    [self.button setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
    [self.button setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
    [self.button setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
    
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    NSInteger num=0;
    CGFloat W=[UIScreen mainScreen].bounds.size.width/5;
    CGFloat H=self.frame.size.height;
    CGFloat Y=0;
    
   
    for (UIView *obj in self.subviews)
    {
        if ([obj isKindOfClass:NSClassFromString(@"UITabBarButton")])
        {
            obj.frame=CGRectMake(W*num, Y, W, H);
            num++;
            if (num==2) {
                num+=1;
            }
        }
        
    }
    self.button.frame=CGRectMake(2*W,  Y, W, H);

}
@end
